SET QUOTED_IDENTIFIER ON
GO
SET ANSI_NULLS ON
GO
CREATE PROCEDURE [dbo].[SP_UPDATE_USER](@LOGIN VARCHAR(25),@PASS VARCHAR(25)) AS
DECLARE @PASS_AUX VARBINARY(256)
 BEGIN TRY
	OPEN SYMMETRIC KEY NDEV_PASSWORD DECRYPTION
	BY CERTIFICATE NDEV
	SET @PASS_AUX = EncryptByKey(Key_GUID('NDEV_PASSWORD'), @PASS)
	
	UPDATE T_USER
	SET USER_PASSWORD = @PASS_AUX
	WHERE USER_LOGIN = @LOGIN

	CLOSE SYMMETRIC KEY NDEV_PASSWORD
	SELECT 'SUCCESS'
	

--EXEC [SP_INSERT_USER] 1,'rcano','123456'

END TRY

BEGIN CATCH
	SELECT 
		ERROR_MESSAGE(),
		ERROR_LINE()
	RETURN 0
	
END CATCH

GO
